<?php
	/**
	 * This is a MetaControl class, providing a QForm or QPanel access to event handlers
	 * and QControls to perform the Create, Edit, and Delete functionality
	 * of the MantisUserPrintPrefTable class.  This code-generated class
	 * contains all the basic elements to help a QPanel or QForm display an HTML form that can
	 * manipulate a single MantisUserPrintPrefTable object.
	 *
	 * To take advantage of some (or all) of these control objects, you
	 * must create a new QForm or QPanel which instantiates a MantisUserPrintPrefTableMetaControl
	 * class.
	 *
	 * Any and all changes to this file will be overwritten with any subsequent
	 * code re-generation.
	 *
	 * @package My QCubed Application
	 * @subpackage MetaControls
	 * @property-read MantisUserPrintPrefTable $MantisUserPrintPrefTable the actual MantisUserPrintPrefTable data class being edited
	 * @property QIntegerTextBox $UserIdControl
	 * @property-read QLabel $UserIdLabel
	 * @property QTextBox $PrintPrefControl
	 * @property-read QLabel $PrintPrefLabel
	 * @property-read string $TitleVerb a verb indicating whether or not this is being edited or created
	 * @property-read boolean $EditMode a boolean indicating whether or not this is being edited or created
	 */

	class MantisUserPrintPrefTableMetaControlGen extends QBaseClass {
		// General Variables
		/**
		 * @var MantisUserPrintPrefTable objMantisUserPrintPrefTable
		 * @access protected
		 */
		protected $objMantisUserPrintPrefTable;
		/**
		 * @var QForm|QControl objParentObject
		 * @access protected
		 */
		protected $objParentObject;
		/**
		 * @var string strTitleVerb
		 * @access protected
		 */
		protected $strTitleVerb;
		/**
		 * @var boolean blnEditMode
		 * @access protected
		 */
		protected $blnEditMode;

		// Controls that allow the editing of MantisUserPrintPrefTable's individual data fields
		/**
		 * @var QIntegerTextBox txtUserId
		 * @access protected
		 */
		protected $txtUserId;
		/**
		 * @var QTextBox txtPrintPref
		 * @access protected
		 */
		protected $txtPrintPref;

		// Controls that allow the viewing of MantisUserPrintPrefTable's individual data fields
		/**
		 * @var QLabel lblUserId
		 * @access protected
		 */
		protected $lblUserId;
		/**
		 * @var QLabel lblPrintPref
		 * @access protected
		 */
		protected $lblPrintPref;

		// QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References

		// QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References


		/**
		 * Main constructor.  Constructor OR static create methods are designed to be called in either
		 * a parent QPanel or the main QForm when wanting to create a
		 * MantisUserPrintPrefTableMetaControl to edit a single MantisUserPrintPrefTable object within the
		 * QPanel or QForm.
		 *
		 * This constructor takes in a single MantisUserPrintPrefTable object, while any of the static
		 * create methods below can be used to construct based off of individual PK ID(s).
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisUserPrintPrefTableMetaControl
		 * @param MantisUserPrintPrefTable $objMantisUserPrintPrefTable new or existing MantisUserPrintPrefTable object
		 */
		 public function __construct($objParentObject, MantisUserPrintPrefTable $objMantisUserPrintPrefTable) {
			// Setup Parent Object (e.g. QForm or QPanel which will be using this MantisUserPrintPrefTableMetaControl)
			$this->objParentObject = $objParentObject;

			// Setup linked MantisUserPrintPrefTable object
			$this->objMantisUserPrintPrefTable = $objMantisUserPrintPrefTable;

			// Figure out if we're Editing or Creating New
			if ($this->objMantisUserPrintPrefTable->__Restored) {
				$this->strTitleVerb = QApplication::Translate('Edit');
				$this->blnEditMode = true;
			} else {
				$this->strTitleVerb = QApplication::Translate('Create');
				$this->blnEditMode = false;
			}
		 }

		/**
		 * Static Helper Method to Create using PK arguments
		 * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
		 * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
		 * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to
		 * edit, or if we are also allowed to create a new one, etc.
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisUserPrintPrefTableMetaControl
		 * @param integer $intUserId primary key value
		 * @param QMetaControlCreateType $intCreateType rules governing MantisUserPrintPrefTable object creation - defaults to CreateOrEdit
 		 * @return MantisUserPrintPrefTableMetaControl
		 */
		public static function Create($objParentObject, $intUserId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			// Attempt to Load from PK Arguments
			if (strlen($intUserId)) {
				$objMantisUserPrintPrefTable = MantisUserPrintPrefTable::Load($intUserId);

				// MantisUserPrintPrefTable was found -- return it!
				if ($objMantisUserPrintPrefTable)
					return new MantisUserPrintPrefTableMetaControl($objParentObject, $objMantisUserPrintPrefTable);

				// If CreateOnRecordNotFound not specified, throw an exception
				else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
					throw new QCallerException('Could not find a MantisUserPrintPrefTable object with PK arguments: ' . $intUserId);

			// If EditOnly is specified, throw an exception
			} else if ($intCreateType == QMetaControlCreateType::EditOnly)
				throw new QCallerException('No PK arguments specified');

			// If we are here, then we need to create a new record
			return new MantisUserPrintPrefTableMetaControl($objParentObject, new MantisUserPrintPrefTable());
		}

		/**
		 * Static Helper Method to Create using PathInfo arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisUserPrintPrefTableMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing MantisUserPrintPrefTable object creation - defaults to CreateOrEdit
		 * @return MantisUserPrintPrefTableMetaControl
		 */
		public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$intUserId = QApplication::PathInfo(0);
			return MantisUserPrintPrefTableMetaControl::Create($objParentObject, $intUserId, $intCreateType);
		}

		/**
		 * Static Helper Method to Create using QueryString arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this MantisUserPrintPrefTableMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing MantisUserPrintPrefTable object creation - defaults to CreateOrEdit
		 * @return MantisUserPrintPrefTableMetaControl
		 */
		public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$intUserId = QApplication::QueryString('intUserId');
			return MantisUserPrintPrefTableMetaControl::Create($objParentObject, $intUserId, $intCreateType);
		}



		///////////////////////////////////////////////
		// PUBLIC CREATE and REFRESH METHODS
		///////////////////////////////////////////////

		/**
		 * Create and setup QIntegerTextBox txtUserId
		 * @param string $strControlId optional ControlId to use
		 * @return QIntegerTextBox
		 */
		public function txtUserId_Create($strControlId = null) {
			$this->txtUserId = new QIntegerTextBox($this->objParentObject, $strControlId);
			$this->txtUserId->Name = QApplication::Translate('User Id');
			$this->txtUserId->Text = $this->objMantisUserPrintPrefTable->UserId;
			$this->txtUserId->Required = true;
			return $this->txtUserId;
		}

		/**
		 * Create and setup QLabel lblUserId
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblUserId_Create($strControlId = null, $strFormat = null) {
			$this->lblUserId = new QLabel($this->objParentObject, $strControlId);
			$this->lblUserId->Name = QApplication::Translate('User Id');
			$this->lblUserId->Text = $this->objMantisUserPrintPrefTable->UserId;
			$this->lblUserId->Required = true;
			$this->lblUserId->Format = $strFormat;
			return $this->lblUserId;
		}

		/**
		 * Create and setup QTextBox txtPrintPref
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtPrintPref_Create($strControlId = null) {
			$this->txtPrintPref = new QTextBox($this->objParentObject, $strControlId);
			$this->txtPrintPref->Name = QApplication::Translate('Print Pref');
			$this->txtPrintPref->Text = $this->objMantisUserPrintPrefTable->PrintPref;
			$this->txtPrintPref->Required = true;
			$this->txtPrintPref->MaxLength = MantisUserPrintPrefTable::PrintPrefMaxLength;
			return $this->txtPrintPref;
		}

		/**
		 * Create and setup QLabel lblPrintPref
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblPrintPref_Create($strControlId = null) {
			$this->lblPrintPref = new QLabel($this->objParentObject, $strControlId);
			$this->lblPrintPref->Name = QApplication::Translate('Print Pref');
			$this->lblPrintPref->Text = $this->objMantisUserPrintPrefTable->PrintPref;
			$this->lblPrintPref->Required = true;
			return $this->lblPrintPref;
		}



		/**
		 * Refresh this MetaControl with Data from the local MantisUserPrintPrefTable object.
		 * @param boolean $blnReload reload MantisUserPrintPrefTable from the database
		 * @return void
		 */
		public function Refresh($blnReload = false) {
			if ($blnReload)
				$this->objMantisUserPrintPrefTable->Reload();

			if ($this->txtUserId) $this->txtUserId->Text = $this->objMantisUserPrintPrefTable->UserId;
			if ($this->lblUserId) $this->lblUserId->Text = $this->objMantisUserPrintPrefTable->UserId;

			if ($this->txtPrintPref) $this->txtPrintPref->Text = $this->objMantisUserPrintPrefTable->PrintPref;
			if ($this->lblPrintPref) $this->lblPrintPref->Text = $this->objMantisUserPrintPrefTable->PrintPref;

		}



		///////////////////////////////////////////////
		// PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
		///////////////////////////////////////////////





		///////////////////////////////////////////////
		// PUBLIC MANTISUSERPRINTPREFTABLE OBJECT MANIPULATORS
		///////////////////////////////////////////////

		/**
		 * This will save this object's MantisUserPrintPrefTable instance,
		 * updating only the fields which have had a control created for it.
		 */
		public function SaveMantisUserPrintPrefTable() {
			try {
				// Update any fields for controls that have been created
				if ($this->txtUserId) $this->objMantisUserPrintPrefTable->UserId = $this->txtUserId->Text;
				if ($this->txtPrintPref) $this->objMantisUserPrintPrefTable->PrintPref = $this->txtPrintPref->Text;

				// Update any UniqueReverseReferences (if any) for controls that have been created for it

				// Save the MantisUserPrintPrefTable object
				$this->objMantisUserPrintPrefTable->Save();

				// Finally, update any ManyToManyReferences (if any)
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * This will DELETE this object's MantisUserPrintPrefTable instance from the database.
		 * It will also unassociate itself from any ManyToManyReferences.
		 */
		public function DeleteMantisUserPrintPrefTable() {
			$this->objMantisUserPrintPrefTable->Delete();
		}



		///////////////////////////////////////////////
		// PUBLIC GETTERS and SETTERS
		///////////////////////////////////////////////

		/**
		 * Override method to perform a property "Get"
		 * This will get the value of $strName
		 *
		 * @param string $strName Name of the property to get
		 * @return mixed
		 */
		public function __get($strName) {
			switch ($strName) {
				// General MetaControlVariables
				case 'MantisUserPrintPrefTable': return $this->objMantisUserPrintPrefTable;
				case 'TitleVerb': return $this->strTitleVerb;
				case 'EditMode': return $this->blnEditMode;

				// Controls that point to MantisUserPrintPrefTable fields -- will be created dynamically if not yet created
				case 'UserIdControl':
					if (!$this->txtUserId) return $this->txtUserId_Create();
					return $this->txtUserId;
				case 'UserIdLabel':
					if (!$this->lblUserId) return $this->lblUserId_Create();
					return $this->lblUserId;
				case 'PrintPrefControl':
					if (!$this->txtPrintPref) return $this->txtPrintPref_Create();
					return $this->txtPrintPref;
				case 'PrintPrefLabel':
					if (!$this->lblPrintPref) return $this->lblPrintPref_Create();
					return $this->lblPrintPref;
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

		/**
		 * Override method to perform a property "Set"
		 * This will set the property $strName to be $mixValue
		 *
		 * @param string $strName Name of the property to set
		 * @param string $mixValue New value of the property
		 * @return mixed
		 */
		public function __set($strName, $mixValue) {
			try {
				switch ($strName) {
					// Controls that point to MantisUserPrintPrefTable fields
					case 'UserIdControl':
						return ($this->txtUserId = QType::Cast($mixValue, 'QControl'));
					case 'PrintPrefControl':
						return ($this->txtPrintPref = QType::Cast($mixValue, 'QControl'));
					default:
						return parent::__set($strName, $mixValue);
				}
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}
	}
?>